import java.util.*;

public class Weilai {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] nm = sc.nextLine()
                .replaceAll("\\[","")
                .replaceAll("\\]","")
                .replaceAll(" ","")
                .split(",");
        List<Integer> arr = new ArrayList<>();
        for (String s:nm){
            if (!s.isEmpty()){
                arr.add(Integer.parseInt(s));
            }
        }
        System.out.println(getArrPairNum(arr));
        return ;
    }

    public static int getArrPairNum(List<Integer> arr){
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int num:arr){
            map.put(num,0);
        }


        for (int num:arr){
            if (map.containsKey(num+1)){
                map.put(num,map.get(num)+1);
            }
        }
        int count=0;
        Iterator<Map.Entry<Integer, Integer>> entries = map.entrySet().iterator();
        while (entries.hasNext()){
            Map.Entry<Integer, Integer> entry = entries.next();
            if (entry.getValue()>0){
                count++;
            }
        }

        return count;
    }


}
